package com.wangwei.jvm.classloader;

public class TestMyClassLoader
{
    public static void main(String[] args) throws Exception{
        //extracted();
        extracted1();
    }

    private static void extracted() throws ClassNotFoundException, InstantiationException, IllegalAccessException {
        MyClassLoader mcl = new MyClassLoader();
        Class<?> c1 = Class.forName("com.wangwei.jvm.Hello", true, mcl);
        Object obj = c1.newInstance();
        System.out.println(obj);
        System.out.println(obj.getClass().getClassLoader());
    }

    private static void extracted1() throws ClassNotFoundException, InstantiationException, IllegalAccessException {
        MyClassLoader mcl = new MyClassLoader();
        Class clazz = mcl.loadClass("com.wangwei.jvm.Hello");
        Object obj = clazz.newInstance();
        System.out.println(obj);
        System.out.println(obj.getClass().getClassLoader());
    }


}